<!DOCTYPE HTML>
<html lang="en">
<head>
<title>SendLevel - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The SendLevel command controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SendLevel <span class="ver">[v1.1.06+]</span></h1>
<p>Controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.</p>
<pre class="Syntax"><span class="func">SendLevel</span>, Level</pre>

<h2>Parameters</h2>
<dl>

  <dt>Level</dt>
  <dd><p>An integer between 0 and 100, which can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd>

</dl>

<h2>General Remarks</h2>
<p>By default, <a href="_UseHook.htm">hook</a> <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a> ignore keyboard and mouse events generated by any AutoHotkey script. In some cases it can be useful to override this behaviour; for instance, to allow a remapped key to be used to trigger other hotkeys. SendLevel and <a href="_InputLevel.htm">#InputLevel</a> provide the means to achieve this.</p>
<p>SendLevel sets the level for events generated by the current <a href="../misc/Threads.htm">script thread</a>, while #InputLevel sets the level for any hotkeys or hotstrings beneath it. For any event generated by a script to trigger a hook hotkey or hotstring, the send level of the event must be higher than the input level of the hotkey or hotstring.</p>
<p>Compatibility:</p>
<ul>
  <li><a href="Send.htm#SendPlayDetail">SendPlay</a> is not affected by SendLevel.</li>
  <li><a href="Send.htm#SendInputDetail">SendInput</a> is affected by SendLevel, but the script's own hook hotkeys cannot be activated while a SendInput is in progress, since it temporarily deactivates the hook. However, when Send or SendInput <a href="Send.htm#SendInputUnavail">reverts to SendEvent</a>, it is able to activate the script's own hotkeys.</li>
  <li>Hotkeys using the <a href="ListHotkeys.htm">&quot;reg&quot;</a> method are incapable of distinguishing physical and artificial input, so are not affected by SendLevel. However, hotkeys above level 0 always use the keyboard or mouse hook.</li>
  <li><a href="../Hotstrings.htm">Hotstrings</a> use #InputLevel only to determine whether the last typed character should trigger a hotstring. For instance, the hotstring <code>::btw::</code> can be triggered regardless of #InputLevel by sending <code>btw</code> at level 1 or higher and physically typing an <a href="../Hotstrings.htm#EndChars">ending character</a>. This is because hotstring recognition works by collecting input from all levels except level 0 into a single global buffer.</li>
  <li>Auto-replace <a href="../Hotstrings.htm">hotstrings</a> always generate keystrokes at level 0, since it is usually undesirable for the replacement text to trigger another hotstring or hotkey. To work around this, use a non-auto-replace hotstring and the SendEvent command.</li>
  <li>Characters sent by the <a href="Send.htm#asc">ASC (Alt+nnnnn)</a> method cannot trigger a hotstring, even if SendLevel is used.</li>
  <li>Characters sent by SendEvent with the <a href="Send.htm#SendText">{Text}</a> mode, <a href="Send.htm#Unicode">{U+nnnn}</a> or <a href="Send.htm#characters">Unicode fallback method</a> can trigger hotstrings.</li>
</ul>
<p><span class="ver">[v1.1.23+]:</span> The built-in variable <strong>A_SendLevel</strong> contains the current setting.</p>
<p>Every newly launched hotkey or hotstring <a href="../misc/Threads.htm">thread</a> starts off with a send level equal to the <a href="_InputLevel.htm">input level</a> of the hotkey or hotstring. Every other newly launched thread (such as a <a href="Menu.htm">custom menu item</a> or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting, which is typically 0 but may be changed by using this command in the <a href="../Scripts.htm#auto">auto-execute section</a>.</p>
<p>If SendLevel is used in the <a href="../Scripts.htm#auto">auto-execute section</a>, it also affects <a href="../misc/Remap.htm">keyboard and mouse remapping</a>.</p>
<p>AutoHotkey versions older than <span class="ver">[v1.1.06]</span> behave as though <code>#InputLevel 0</code> and <code>SendLevel 0</code> are in effect.</p>

<h2>Related</h2>
<p><a href="_InputLevel.htm">#InputLevel</a>, <a href="Send.htm">Send</a>, <a href="Click.htm">Click</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a></p>

<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>
SendLevel 1
Send btw{Space} <em>; Produces "by the way ".</em>

<em>; This may be defined in a separate script:</em>
::btw::by the way
</pre>
</div>

</body>
</html>
